<!-- 股东研究 -->
<template>
    <div class="partner w1021">
        <!-- 股东人数 -->
        <yn-com-comTitle name="股东人数"></yn-com-comTitle>
        <yn-partner-partnerNum :data="stockHolderNum"></yn-partner-partnerNum>
        <!-- 十大流通股东 -->
        <yn-com-comTitle class="mt15" name="十大流通股东"></yn-com-comTitle>
        <yn-partner-tenCurrency :data="cirStockHolder"></yn-partner-tenCurrency>
        <!-- 十大股东 -->
        <yn-com-comTitle class="mt15" name="十大股东"></yn-com-comTitle>
        <yn-partner-tenPartner :data="mianStockHolder"></yn-partner-tenPartner>
        <!-- 机构持股汇总 -->
        <yn-com-comTitle class="mt15" name="机构持股汇总"></yn-com-comTitle>
        <yn-partner-shareHolding :data="orgStockHolder"></yn-partner-shareHolding>
        <!-- 限售解禁 -->
        <yn-com-comTitle class="mt15" name="限售解禁"></yn-com-comTitle>
        <yn-partner-limitSales :data="limitedStock"></yn-partner-limitSales>
    </div>
</template>

<script>
import { getHolder } from "../script/api";
import zip from "lodash/zip";
import echarts from "echarts";

const className = (ops) => {
    let val = "";
    val = ops != 0 && ops > 0 ? "colorRed" : "colorGreen";
    if (ops == 0 || ops == null) {
        val = "";
    }
    return { val, name: ops };
};
const classNameStr = (ops) => {
    let val = "";
    val = ops.indexOf("-") != -1 ? "colorGreen" : "colorRed";
    if (ops == "不变" || ops == "新进" || ops == null || ops == "") {
        val = "";
    }
    return { val };
};
const handle = (arr) => {
    return arr.map((item) => {
        // item._inrDecNumClass = classNameStr(item.inrDecNum).val;
        item._inrDecNumClass = item.inrDecNum;
        return item;
    });
};
const handleNum = (arr) => {
    return arr.map((item) => {
        item._totShrPctB = item.totShrPctB ? item.totShrPctB : "--";
        item._totShrPctA = item.totShrPctA ? item.totShrPctA : "--";

        item._avgNumQtrGr = className(item.avgNumQtrGr).name;
        item._avgNumQtrGrClass = className(item.avgNumQtrGr).val;

        item._avgPctQtrGr = className(item.avgPctQtrGr).name;
        item._avgPctQtrGrClass = className(item.avgPctQtrGr).val;

        item._avgNum6MthGr = className(item.avgNum6MthGr).name;
        item._avgNum6MthGrClass = className(item.avgNum6MthGr).val;

        item._avgPct6MthGr = className(item.avgPct6MthGr).name;
        item._avgPct6MthGrClass = className(item.avgPct6MthGr).val;
        return item;
    });
};
export default {
    data() {
        return {
            stockHolderNum: [], //股东人数
            cirStockHolder: [], //十大流通股东
            mianStockHolder: [], //十大股东
            limitedStock: [], //限售解禁
            orgStockHolder: [], //机构持股汇总
        };
    },
    mounted() {
        this.getData();
    },
    methods: {
        async getData() {
            //公司新闻
            //todo
            const res = await getHolder();
            this.stockHolderNum = handleNum(res.stockHolderNum); //股东人数
            this.cirStockHolder = res.cirStockHolder; //十大流通股东
            console.log("tenCurrency===>", this.cirStockHolder);
            this.mianStockHolder = res.mianStockHolder; //十大股东
            console.log("mianStockHolder===>", this.mianStockHolder);
            this.limitedStock = res.limitedStock ? res.limitedStock : []; //限售解禁
            this.orgStockHolder = res.orgStockHolderNew; // 机构持股汇总
            console.log("this.orgStockHolder", this.orgStockHolder);
        },
    },
};
</script>
